<template>
    <div>
        <child-header>
            <template #title>
                <div>
                    个人信息
                </div>
            </template>
        </child-header>
        <div class="avatar-content">
            <van-image v-if="avatar !== ''" round width="5rem" height="5rem" :src="avatar" />
            <van-uploader v-else :after-read="afterRead" />
        </div>
        <van-form @submit="onSubmit">
            <van-cell-group inset>
                <van-field v-model="username" name="用户名" label="用户名" placeholder="用户名"
                    :rules="[{ required: true, message: '请填写用户名' }]" disabled/>
                <van-field v-model="password" type="password" name="密码" label="密码" placeholder="密码"
                    :rules="[{ required: true, message: '请填写密码' }]" />
            </van-cell-group>
            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit">
                    提交
                </van-button>
            </div>
        </van-form>
    </div>
</template>

<script setup>
import ChildHeader from '@/components/ChildHeader.vue'
import { ref } from 'vue'

const avatar = ref('https://foruda.gitee.com/avatar/1715931924378943527/5352827_adnaan_1715931924.png!avatar200')
const username = ref('123456');
const password = ref('123456');
const onSubmit = (values) => {
    console.log('submit', values);
};
const afterRead = (file) => {
    avatar.value = file.content;
};
</script>

<style scoped>
.avatar-content {
    text-align: center;
}
</style>